package technology;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnectionFactory;

public class MyList implements MessageListener{

	@Override
	public void onMessage(Message arg0) {
		try{
			ObjectMessage message=(ObjectMessage)arg0;
			String str=message.getStringProperty("test");
			System.out.println(str);
		}catch (Exception e) {
			e.printStackTrace();
		}
		
		
	}
	
	
	public MyList(){
		try{
			ConnectionFactory factory=new ActiveMQConnectionFactory("tcp://0.0.0.0:61616");
			factory.createConnection();
			Connection connection=factory.createConnection();
			Session session=connection.createSession(Boolean.TRUE,Session.AUTO_ACKNOWLEDGE);
			Destination destination=session.createQueue("queue");
			MessageConsumer consumer=session.createConsumer(destination);
			consumer.setMessageListener(this);
			connection.start();
			Thread.sleep(10000);
			connection.stop();
		}catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args){
		MyList list=new MyList();
		MySender mySender=new MySender();
		
		
	}

}
